﻿using System;
using System.Linq;

namespace eCommerce.DataAccess
{
    public class AddressDA
    {
        private eCommerceDataContext _dataBase = new eCommerceDataContext();

        /// <summary>
        /// Gets the customer address.
        /// </summary>
        /// <param name="userId">The user id.</param>
        /// <returns></returns>
        public AddressType GetCustomerAddress(Guid userId)
        {
            var customerAddress = from s in _dataBase.Addresses
                    join t in _dataBase.AddressUsers on s.AddressID equals t.addressid
                    join p in _dataBase.AddressTypes on t.addresstype equals p.ID into ps
                    where t.userid == userId
                    select ps;

            return customerAddress.First().First();
        }

    }
}
